﻿using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CutShuFa.AutoAction
{
    public class ActionFindContoursExternal : AAutoAction
    {
        public override string ActionName
        {
            get
            {
                return "查找外层轮廓";
            }
        }

        public override List<Parameter> GetParameters()
        {
            if (parameters == null)
            {
                parameters = new List<Parameter>();
                parameters.Add(new Parameter() { Name = "input", Value = "src_mat", Type = ParameterType.Mat });
            }
            return parameters;
        }

        public override void Run(AutoActionData data)
        {
            if (this.parameters == null)
            {
                GetParameters();
            }
            string input = parameters.Where(p => p.Name == "input").FirstOrDefault().Value;
            Cv2.FindContours(data.matDic[input], out data.contours, out HierarchyIndex[] hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
        }

    }
}
